#pragma once

#include <AVUIContentElement.h>
#include <AVUITreeChangeInfo.h>

namespace AVUI {

class Style;
class ResourceDictionary;
class XmlLanguage;
class FrameworkContentElement : public ContentElement
{
    friend class FrameworkObject;
    friend class FrameworkElement;
    friend class Helper;
public:

    DECLARE_ELEMENT(FrameworkContentElement, ContentElement);

    virtual void BeginInit() { };
    virtual void EndInit() { };

    Object* FindName(const String& Name) { return NULL; };
    Object* FindName(const String& Name, DependencyObject** ppScopeOwner) { return NULL; };
    Object* FindName(String* pName, DependencyObject** ppScopeOwner) { return NULL; };

    DependencyObject* get_Parent() { return NULL; }

    void RaiseEvent(RoutedEventArgs* pArgs) { };

    IMPLEMENT_ROUTED_EVENT(Loaded, RoutedEventArgs, RoutingStrategy::Broadcast);
    IMPLEMENT_ROUTED_EVENT(Unloaded, RoutedEventArgs, RoutingStrategy::Broadcast);
    IMPLEMENT_EVENT(ResourcesChanged, EventArgs);

    static DependencyProperty* get_StyleProperty() { return NULL; }
    Style* get_Style() { return NULL; }
    Style* get_ThemeStyle() { return NULL; }
    DependencyObject* get_TemplatedParent() { return NULL; }
    int get_TemplateChildIndex() { return -1; }
    void set_TemplateChildIndex(int value) { }
    InheritanceBehavior::Enum get_InheritanceBehavior() { return InheritanceBehavior::Default; }

    ResourceDictionary* get_Resources() { return NULL; }
    bool get_HasResources() { return false; }
    bool get_ShouldLookupImplicitStyles() { return false; }
    bool get_HasLogicalChildren() { return false; }

    bool get_HasLocalStyle() { return false; }
    void set_HasLocalStyle(bool value) { }
    bool get_HasStyleChanged() { return false; }
    void set_HasStyleChanged(bool value) { }
    bool get_HasStyleInvalidated() { return false; }
    void set_HasStyleInvalidated(bool value) { }

    bool get_HasResourceReference() { return false; }
    void set_HasResourceReference(bool value) { }

    bool get_HasImplicitStyleFromResources() { return false; }
    void set_HasImplicitStyleFromResources(bool value) { }
    void set_ShouldLookupImplicitStyles(bool value) { }
    bool get_StoresParentTemplateValues() { return false; }
    void set_StoresParentTemplateValues(bool value) { }

    bool get_AncestorChangeInProgress() { return false; }
    void set_AncestorChangeInProgress(bool value) { }

    bool get_PotentiallyHasMentees() { return false; }
    bool get_IsRequestingExpression() { return false; }

    void set_IsLogicalChildrenIterationInProgress(bool value) { }
    void set_IsLoadedCache(bool value) { }
    bool get_SubtreeHasLoadedChangeHandler() { return false; }
    Object* get_LoadedPending() { return NULL; }
    Object* get_UnloadedPending() { return NULL; }
    void FireLoadedOnDescendentsInternal() { }
    void FireUnloadedOnDescendentsInternal() { }

    void set_IsTemplatedParentAnFE(bool value) { }

    void UpdateStyleProperty() { }
    void UpdateThemeStyleProperty() { }
    void OnAncestorChangedInternal(TreeChangeInfo parentTreeState) { };

    bool get_HasTemplateGeneratedSubTree() { return false; }
    void set_HasTemplateGeneratedSubTree(bool value) { }

    static DependencyProperty* StyleProperty;

    void RaiseClrEvent(Object* pKey, EventArgs* pArgs) { InvokeEventHandler(pKey, this, pArgs); }

    virtual TRefCountedPtr<Object> get_LogicalChildren() { return NULL; }
    void ChangeSubtreeHasLoadedChangedHandler(DependencyObject* pMentor) { }
    void RaiseInheritedPropertyChangedEvent(InheritablePropertyChangeInfo* pInfo) { };
    bool get_IsParentAnFE() { return true; }
    bool get_IsInitialized() { return true; }
    bool get_IsLoaded() { return true; }
    bool get_OverridesDefaultStyle() { return true; }
    bool get_IsStyleSetFromGenerator() { return false; }
    void set_IsStyleSetFromGenerator(bool value) {  }
    void set_SubtreeHasLoadedChangeHandler(bool value) {  }
    void set_HasThemeStyleEverBeenFetched(bool value) {  }
    XmlLanguage* get_Language() { return NULL; }
    void set_Style(Style* pValue) {  }
    bool get_ThisHasLoadedChangeEventHandler() { return false; }
    static void OnThemeStyleChanged(DependencyObject* pDO, Object* pOldValue, Object* pNewValue) { };

    void add_InheritedPropertyChanged(InheritedPropertyChangedEventHandler* pValue) { }
    void remove_InheritedPropertyChanged(InheritedPropertyChangedEventHandler* pValue) { }
    void BringIntoView() { }
    void AddLogicalChild(Object* pLogicalChild) { }
    void RemoveLogicalChild(Object* pLogicalChild) { }

    TWeakPtr<DependencyObject> m_pTemplatedParent;

    virtual void OnStyleChanged(Style* pOldStyle, Style* pNewStyle) { }

    TRefCountedPtr<Object> get_DefaultStyleKey() { return (Object*)GetValue(get_DefaultStyleKeyProperty()); }
    void set_DefaultStyleKey(Object* pValue) { SetValue(get_DefaultStyleKeyProperty(), pValue); } 
    DECLARE_DEPENDENCY_PROPERTY(DefaultStyleKey);

protected:

    virtual DependencyObject* GetUIParentCore() { return get_Parent(); }
    void GetRawValue(DependencyProperty* pDP, PropertyMetadata* pMetadata, EffectiveValueEntry* pEntry) { };


private:
    TRefCountedPtr<ResourceDictionary> m_pResources;

    void OnLoaded(RoutedEventArgs* pArgs) { RaiseEvent(pArgs); }
    void OnUnloaded(RoutedEventArgs* pArgs) { RaiseEvent(pArgs); }

    void ChangeLogicalParent(DependencyObject* pNewParent) { };
    Object* FindResourceOnSelf(Object* pResourceKey, bool allowDeferredResourceReference, bool mustReturnDeferredResourceReference) { return NULL; }

};


}; // namespace AVUI
